package by.gamedev.site.client.app.ui;

import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.text.shared.AbstractRenderer;
import com.google.gwt.text.shared.Renderer;

/**
 * A simple renderer of Float values.
 */
public class FloatRenderer extends AbstractRenderer<Float> {
    private static FloatRenderer INSTANCE;

    /**
     * @return the instance
     */
    public static Renderer<Float> instance() {
        if(INSTANCE == null ) {
            INSTANCE = new FloatRenderer();
        }
        return INSTANCE;
    }

    protected FloatRenderer() {
        // nothing
    }

    @Override
    public String render(final Float object) {
        if(object == null ) {
            return "";
        }

        return NumberFormat.getDecimalFormat().format(object);
    }
}
